<?php
/**
  * YAML Green WordPress Theme
  *
  * @copyright       Copyright 2008, dynamicinternet GmbH
  * @link            http://dynamicinternet.eu/wordpress/wordpress-themes/yaml-green-theme/
  * @license         CC-A 2.0 (http://creativecommons.org/licenses/by/2.0/),
  *                  YAML-C (http://www.yaml.de/en/license/license-conditions.html)
  * @author          $Author: michael $
  * @version         1.2.2
  * @revision        $Revision: 60 $
  * @lastmodified    $Date: 2008-12-10 19:27:11 +0100 (Mi, 10 Dez 2008) $
  */
class di_yaml_config {

	var $yamloptions;
	
	function di_yaml_config() {
		$this->yamloptions = $this->di_getOptions();
	}
	function di_initAdmin() {
		if (!is_array($this->yamloptions)) {
			$this->di_setDefaultOptions();
		} elseif (isset($_POST['yaml_config_save'])) {
			$this->di_saveOptions();
		} elseif (isset($_POST['yaml_config_default'])) {
			$this->di_setDefaultOptions();
		}
		add_theme_page("YAML Green Theme Options", "Current Theme Options", 'edit_themes', basename(__FILE__), array(&$this, 'di_displayOptions'));
	}

	function di_getOptions() {
		 return get_option('di_yaml_green');
	}

	function di_setDefaultOptions() {
		$this->yamloptions = array();
		$this->yamloptions['di_layout'] = 1; // 2 columns, right sidebar
		$this->yamloptions['di_secondsidebar'] = 0; // not splitted
		$this->yamloptions['di_contentwidth'] = 66; // 66%
		$this->yamloptions['di_txtalign'] = 0; //left
		$this->yamloptions['di_login'] = 1; //yes
		$this->yamloptions['di_navi'] = 2;
		$this->yamloptions['di_navisearch'] = 1;
		$this->yamloptions['di_searchwidth'] = 23;
		$this->yamloptions['di_subcolumn'] = 3;
		$this->yamloptions['di_bloglogo'] = 1;
		$this->yamloptions['di_blogdescription'] = 1;
		$this->yamloptions['di_blogtitle'] = 1;
		$this->yamloptions['di_index_contenttype'] = 0;
		$this->yamloptions['di_other_contenttype'] = 0;
		$this->yamloptions['di_index_infotype'] = 1;
		$this->yamloptions['di_single_infobox'] = 1;
		$this->yamloptions['di_homelink'] = 1;
		$this->yamloptions['di_subcol_1'] = 2; //left
		$this->yamloptions['di_subcol_2'] = 3; //center
		$this->yamloptions['di_subcol_3'] = 1; //right

		update_option('di_yaml_green', $this->yamloptions);
	}
	function di_getOptionValue($key) {
			return ((int) $this->yamloptions[$key]);
	}

	function di_saveOptions() {
		$this->yamloptions['di_layout'] = strip_tags(stripslashes($_POST['di_layoutselect']));
		$this->yamloptions['di_secondsidebar'] = strip_tags(stripslashes($_POST['di_secondsidebar']));
		
		$tempvalue = (int) strip_tags(stripslashes($_POST['di_contentwidth']));
		if ( $tempvalue < 50 ) {
			$this->yamloptions['di_contentwidth'] = 50;
		} elseif ( $tempvalue > 80 ) {
			$this->yamloptions['di_contentwidth'] = 80;
		} else {
			$this->yamloptions['di_contentwidth'] = $tempvalue;
		}
		
		$sw = (int) strip_tags(stripslashes($_POST['di_searchwidth']));
		if ( $sw < 5) {
			$this->yamloptions['di_searchwidth'] = 5;
		} elseif ( $sw > 30 ) {
			$this->yamloptions['di_searchwidth'] = 30;
		} else {
			$this->yamloptions['di_searchwidth'] = $sw;
		}
		
		$this->yamloptions['di_txtalign'] = strip_tags(stripslashes($_POST['di_txtalign']));
		$this->yamloptions['di_navi'] = strip_tags(stripslashes($_POST['di_naviselect']));
		$this->yamloptions['di_login'] = strip_tags(stripslashes($_POST['di_loginselect']));
		$this->yamloptions['di_subcolumn'] = strip_tags(stripslashes($_POST['di_subcolumnselect']));
		$this->yamloptions['di_index_contenttype'] = strip_tags(stripslashes($_POST['di_index_content_type']));
		$this->yamloptions['di_other_contenttype'] = strip_tags(stripslashes($_POST['di_other_content_type']));
		$this->yamloptions['di_index_infotype'] = strip_tags(stripslashes($_POST['di_index_infotype']));
		$this->yamloptions['di_single_infobox'] = strip_tags(stripslashes($_POST['di_single_infobox']));
		$this->yamloptions['di_subcol_1'] = strip_tags(stripslashes($_POST['di_subcol_1']));
		$this->yamloptions['di_subcol_2'] = strip_tags(stripslashes($_POST['di_subcol_2']));
		$this->yamloptions['di_subcol_3'] = strip_tags(stripslashes($_POST['di_subcol_3']));
		
		if (isset($_POST['di_bloglogo'])) {
			$this->yamloptions['di_bloglogo'] = strip_tags(stripslashes($_POST['di_bloglogo']));
		} else {
			$this->yamloptions['di_bloglogo'] = 0;
		}
			
		if (isset($_POST['di_blogtitle'])) {
			$this->yamloptions['di_blogtitle'] = strip_tags(stripslashes($_POST['di_blogtitle']));
		} else {
			$this->yamloptions['di_blogtitle'] = 0;
		}
		
		if (isset($_POST['di_blogdescription'])) {
			$this->yamloptions['di_blogdescription'] = strip_tags(stripslashes($_POST['di_blogdescription']));
		} else {
			$this->yamloptions['di_blogdescription'] = 0;
		}
		
		if (isset($_POST['di_homelink'])) {
			$this->yamloptions['di_homelink'] = strip_tags(stripslashes($_POST['di_homelink']));
		} else {
			$this->yamloptions['di_homelink'] = 0;
		}
		if (isset($_POST['di_navisearch'])) {		
			$this->yamloptions['di_navisearch'] = strip_tags(stripslashes($_POST['di_navisearch']));
		} else {
			$this->yamloptions['di_navisearch'] = 0;
		}

		update_option('di_yaml_green', $this->yamloptions);
	}

	function di_loadStylesheets() {
		$this->yamloptions = $this->di_getOptions();
		$layout = $this->di_getOptionValue('di_layout');
		switch ($layout) {
			case 1: 
				$stylesheet = "css/green_2col_right.css";
				$iestyle = "css/patches/patch_2col_right_seo.css";
				break;
			case 2: 
				$stylesheet = "css/green_2col_left.css";
				$iestyle = "css/patches/patch_2col_right_seo.css";
				break;
			case 3: 
				$stylesheet = "css/green_3col_fixed.css";
				$iestyle = "css/patches/patch_3col_fixed_seo.css"; 
				break;
		}
?>
<link href="<?php bloginfo('template_url'); ?>/<?php echo $stylesheet; ?>" rel="stylesheet" type="text/css"/>
<!--[if lte IE 7]>
<link href="<?php bloginfo('template_url'); ?>/<?php echo $iestyle; ?>" rel="stylesheet" type="text/css" />
<![endif]-->
<?php
		if ($layout !== 3) {
			$width = $this->di_getOptionValue('di_contentwidth');
			if($width === 66) {
				$awidth = 66.666;
			} else {
				$awidth = $width;
			}
			$col1 = '#col1 { width: ' . $awidth . '% }';
			switch ($layout) {
				case 2: $col3 = '#col3 { margin-right: ' . $awidth . '% }'; break;
				case 1: $col3 = '#col3 { margin-left: ' . $awidth . '% }'; break;
			}
		}
		if ($this->di_getOptionValue('di_navisearch') === 1) {
			$searchwidth = " #navisearch { width: " . $this->di_getOptionValue('di_searchwidth') ."em !important; } #navisearch #s { width: " . $this->di_getOptionValue('di_searchwidth') ."em !important; }";
		} 
if (isset($col1) || isset($col3) || isset($searchwidth)) : ?>
<style type="text/css">
<?php
  echo $col1 ;
  echo $col3 ;
  echo $searchwidth ;
?>
</style>
<?php endif;
}

	function di_displayOptions() {
		if (is_admin()) { ?>
		<div class="wrap">
			<h2>YAML Config Green Theme Options</h2>
			<form action="#" method="post" enctype="multipart/form-data" name="yaml_config_form" id="yaml_config_form">
			<div class="tablenav">
				<div class="alignleft">
					<input type="submit" name="yaml_config_save" value="<?php _e('Optionen speichern', 'dynamicinternet'); ?>" class="button-secondary"/>
					<input type="submit" name="yaml_config_default" value="<?php _e('Default Einstellungen laden', 'dynamicinternet'); ?>" class="button-secondary"/>
				</div>
				<br class="clear">
			</div>
			<br class="clear">
			<?php if(isset($_POST['yaml_config_save'])) :?>
			<div id="message" class="updated fade" style="background-color: rgb(255, 251, 204);">
				<p><?php _e('Optionen gespeichert!', 'dynamicinternet'); ?></p>
			</div>
			<br class="clear">
			<?php endif; ?>
			<?php if(isset($_POST['yaml_config_default'])) :?>
			<div id="message" class="updated fade" style="background-color: rgb(255, 251, 204);">
				<p><?php _e('Default Einstellungen geladen!', 'dynamicinternet'); ?></p>
			</div>
			<br class="clear">
			<?php endif; ?>
				<table class="widefat" >
					<thead>
						<tr>
							<th colspan="3"><?php _e('Grundlayout Einstellungen', 'dynamicinternet'); ?></th>
						</tr>
					</thead> 
						<tr>
							<td width="20%" align="right"><?php _e('w&auml;hle Dein Layout ', 'dynamicinternet'); ?>:</td>
							<td width="25%">
								<select id="di_layoutselect" tabindex="1" name="di_layoutselect">
									<option value="1" <?php if($this->di_getOptionValue('di_layout') === 1){echo 'selected';}; ?>><?php _e('2-spaltig, Sidebar rechts', 'dynamicinternet'); ?></option>
									<option value="2" <?php if($this->di_getOptionValue('di_layout') === 2){echo 'selected';}; ?>><?php _e('2-spaltig, Sidebar links', 'dynamicinternet'); ?></option>
									<option value="3" <?php if($this->di_getOptionValue('di_layout') === 3){echo 'selected';}; ?>><?php _e('3-spaltig, Sidebar rechts und links', 'dynamicinternet'); ?></option>
								</select>
							</td>
							<td>&nbsp;</td>
						</tr>
						<tr>
							<td width="20%" align="right"><?php _e('Sidebar geteilt 50/50', 'dynamicinternet'); ?>:</td>
							<td>
								<select id="di_secondsidebar" tabindex="2" name="di_secondsidebar">
									<option value="0" <?php if($this->di_getOptionValue('di_secondsidebar') === 0){echo 'selected';}; ?>><?php _e('nein', 'dynamicinternet'); ?></option>
									<option value="1" <?php if($this->di_getOptionValue('di_secondsidebar') === 1){echo 'selected';}; ?>><?php _e('ja', 'dynamicinternet'); ?></option>
								</select>
							</td>
							<td><?php _e('nur bei 2-spaltigem Layout m&ouml;glich', 'dynamicinternet'); ?></td>
						</tr>
						<tr>
							<td width="20%" align="right"><?php _e('Textausrichtung in linker Sidebar', 'dynamicinternet'); ?>:</td>
							<td>
								<select id="di_txtalign" tabindex="3" name="di_txtalign">
									<option value="0" <?php if($this->di_getOptionValue('di_txtalign') === 0){echo 'selected';}; ?>><?php _e('links', 'dynamicinternet'); ?></option>
									<option value="1" <?php if($this->di_getOptionValue('di_txtalign') === 1){echo 'selected';}; ?>><?php _e('rechts', 'dynamicinternet'); ?></option>
								</select>
							</td>
							<td><?php _e('nur wenn linke Sidebar vorhanden', 'dynamicinternet'); ?></td>
						</tr>
						<tr>
							<td width="20%" align="right"><?php _e('Breite des Inhaltsbereiches', 'dynamicinternet'); ?></td>
							<td>
								<input type="text" id="di_contentwidth" tabindex="4" name="di_contentwidth"  maxlength="2" size="2" value="<?php echo $this->di_getOptionValue('di_contentwidth'); ?>">&nbsp;%
							</td>
							<td><?php _e('Wert zwischen 50 und 80. Nur bei 2-spaltigem Layout', 'dynamicinternet'); ?></td>
						</tr>
						<tr>
							<td width="20%" align="right"><?php _e('Login Navigation', 'dynamicinternet'); ?>:</td>
							<td>
								<select id="di_loginselect" tabindex="5" name="di_loginselect">
									<option value="0" <?php if($this->di_getOptionValue('di_login') === 0){echo 'selected';}; ?>><?php _e('keine', 'dynamicinternet'); ?></option>
									<option value="1" <?php if($this->di_getOptionValue('di_login') === 1){echo 'selected';}; ?>><?php _e('&uuml;ber dem Header', 'dynamicinternet'); ?></option>
									<option value="2" <?php if($this->di_getOptionValue('di_login') === 2){echo 'selected';}; ?>><?php _e('im Header', 'dynamicinternet'); ?></option>
								</select>
							</td>
							<td><?php _e('eine Navigation f&uuml;r Login/Logout', 'dynamicinternet'); ?></td>
						</tr>
						<tr>
							<td width="20%" align="right"><?php _e('Hauptnavigation', 'dynamicinternet'); ?>:</td>
							<td >
								<select id="di_naviselect" tabindex="6" name="di_naviselect">
									<option value="0" <?php if($this->di_getOptionValue('di_navi') === 0){echo 'selected';}; ?>><?php _e('keine', 'dynamicinternet'); ?></option>
									<option value="2" <?php if($this->di_getOptionValue('di_navi') === 2){echo 'selected';}; ?>><?php _e('unter dem Header', 'dynamicinternet'); ?></option>
								</select>
							</td>
							<td><?php _e('Eine horizontale Navigationsleite f&uuml;r die Hauptseiten', 'dynamicinternet'); ?></td>
						</tr>
						<tr>
							<td width="20%" align="right"><?php _e('zus&auml;tzlicher Container &uuml;ber dem Footer', 'dynamicinternet'); ?>:</td>
							<td>
								<select id="di_subcolumnselect" tabindex="7" name="di_subcolumnselect">
									<option value="0" <?php if($this->di_getOptionValue('di_subcolumn') === 0){echo 'selected';}; ?>><?php _e('keiner', 'dynamicinternet'); ?></option>
									<option value="1" <?php if($this->di_getOptionValue('di_subcolumn') === 1){echo 'selected';}; ?>><?php _e('mit einer Spalte', 'dynamicinternet'); ?></option>
									<option value="2" <?php if($this->di_getOptionValue('di_subcolumn') === 2){echo 'selected';}; ?>><?php _e('mit zwei Spalten', 'dynamicinternet'); ?></option>
									<option value="3" <?php if($this->di_getOptionValue('di_subcolumn') === 3){echo 'selected';}; ?>><?php _e('mit drei Spalten', 'dynamicinternet'); ?></option>
								</select>
							</td>
							<td><?php _e('Die Textausrichtung kannst du weiter unten einstellen', 'dynamicinternet'); ?></td>
						</tr>
					</table>
					<table class="widefat">
						<thead>
							<tr>
								<th colspan="3"><?php _e('Header Einstellungen', 'dynamicinternet'); ?></th>
							</tr>
						</thead> 
						<tr>
							<td width="20%" align="right"><?php _e('Anzeige des Blogtitels', 'dynamicinternet'); ?>:</td>
							<td width="25%">
								<input type="checkbox" id="di_blogtitle" name="di_blogtitle" tabindex="8" value="1" <?php if ($this->di_getOptionValue('di_blogtitle') === 1) {echo "checked=checked";} ?>/>
							</td>
							<td><?php _e('Blendet den Blogtitel ein/aus. Siehe Allgemeine Einstellungen->Blogtitel', 'dynamicinternet'); ?></td>
						</tr>
						<tr>
							<td width="20%" align="right"><?php _e('Anzeige des Blogslogan', 'dynamicinternet'); ?>:</td>
							<td>
								<input type="checkbox" id="di_blogdescription" name="di_blogdescription" tabindex="9" value="1" <?php if ($this->di_getOptionValue('di_blogdescription') === 1) {echo "checked=checked";} ?>/>
							</td>
							<td><?php _e('Blendet den Blogtitel ein/aus. Siehe Allgemeine Einstellungen->Slogan', 'dynamicinternet'); ?></td>
						</tr>
						<tr>
							<td width="20%" align="right"><?php _e('Anzeige des Logos', 'dynamicinternet'); ?>:</td>
							<td>
								<input type="checkbox" id="di_bloglogo" name="di_bloglogo" tabindex="10" value="1" <?php if ($this->di_getOptionValue('di_bloglogo') === 1) {echo "checked=checked";} ?>/>
							</td>
							<td><?php _e('Blendet das Bloglogo ein/aus.', 'dynamicinternet'); ?></td>
						</tr>
					</table>
					<table class="widefat">
						<thead>
							<tr>
								<th colspan="3"><?php _e('Hauptnavigation Einstellungen', 'dynamicinternet'); ?></th>
							</tr>
						</thead> 
						<tr>
							<td width="20%" align="right"><?php _e('Suchefeld in der Navigation', 'dynamicinternet'); ?>:</td>
							<td width="25%">
								<input type="checkbox" id="di_navisearch" name="di_navisearch" tabindex="11" value="1" <?php if ($this->di_getOptionValue('di_navisearch') === 1) {echo "checked=checked";} ?>/>
							</td>
							<td><?php _e('wenn Navigationsleiste vorhanden', 'dynamicinternet'); ?></td>
						</tr>
						<tr>
							<td width="20%" align="right"><?php _e('Breite des Suchefeldes in der Hauptnavigation', 'dynamicinternet'); ?>:</td>
							<td width="25%">
								<input type="text" id="di_searchwidth" tabindex="12" name="di_searchwidth"  maxlength="3" size="3" value="<?php echo $this->di_getOptionValue('di_searchwidth'); ?>">&nbsp;em
							</td>
							<td><?php _e('Wert zwischen 5 und 30', 'dynamicinternet'); ?></td>
						</tr>
						<tr>
							<td width="20%" align="right"><?php _e('Home Link in der Hauptnavigation', 'dynamicinternet'); ?>:</td>
							<td width="25%">
								<input type="checkbox" id="di_homelink" name="di_homelink" tabindex="13" value="1" <?php if ($this->di_getOptionValue('di_homelink') === 1) {echo "checked=checked";} ?>/>
							</td>
							<td><?php _e('Ein Link zur Startseite', 'dynamicinternet'); ?></td>
						</tr>
					</table>
					<table class="widefat">
						<thead>
							<tr>
								<th colspan="3"><?php _e('Anzeige des Inhalts', 'dynamicinternet'); ?></th>
							</tr>
						</thead> 
						<tr>
							<td width="20%" align="right"><?php _e('auf der Blogstartseite', 'dynamicinternet'); ?>:</td>
							<td width="25%">
								<select id="di_index_content_type" tabindex="14" name="di_index_content_type">
									<option value="0" <?php if($this->di_getOptionValue('di_index_contenttype') === 0){echo 'selected';}; ?>><?php _e('gek&uuml;rzte Fassung', 'dynamicinternet'); ?></option>
									<option value="1" <?php if($this->di_getOptionValue('di_index_contenttype') === 1){echo 'selected';}; ?>><?php _e('voller Beitrag', 'dynamicinternet'); ?></option>
								</select>
							</td>
							<td><?php _e('bei gek&uuml;rzter Fassung: wenn vorhanden, der optionale Auszug, sonst die ersten 55 Worte', 'dynamicinternet'); ?></td>
						</tr>
						<tr>
							<td width="20%" align="right"><?php _e('auf den Archiv-/Tag-/Kategorieseiten', 'dynamicinternet'); ?>:</td>
							<td width="25%">
								<select id="di_other_content_type" tabindex="15" name="di_other_content_type">
									<option value="0" <?php if($this->di_getOptionValue('di_other_contenttype') === 0){echo 'selected';}; ?>><?php _e('gek&uuml;rzte Fassung', 'dynamicinternet'); ?></option>
									<option value="1" <?php if($this->di_getOptionValue('di_other_contenttype') === 1){echo 'selected';}; ?>><?php _e('voller Beitrag', ''); ?></option>
								</select>
							</td>
							<td><?php _e('bei gek&uuml;rzter Fassung: wenn vorhanden, der optionale Auszug, sonst die ersten 55 Worte', 'dynamicinternet'); ?></td>
						</tr>
						<tr>
							<td width="20%" align="right"><?php _e('Anzeige der Beitragsinformationen', 'dynamicinternet'); ?>:</td>
							<td width="25%">
								<select id="di_index_infotype" tabindex="16" name="di_index_infotype">
									<option value="0" <?php if($this->di_getOptionValue('di_index_infotype') === 0){echo 'selected';}; ?>><?php _e('nein', 'dynamicinternet'); ?></option>
									<option value="1" <?php if($this->di_getOptionValue('di_index_infotype') === 1){echo 'selected';}; ?>><?php _e('ja', 'dynamicinternet'); ?></option>
								</select>
							</td>
							<td><?php _e('eine Zeile mit Autor/Datum/Kategorie unter der Beitrags&uuml;berschrift', 'dynamicinternet'); ?></td>
						</tr>
						<tr>
							<td width="20%" align="right"><?php _e('Anzeige einer Infobox', 'dynamicinternet'); ?>:</td>
							<td width="25%">
								<select id="di_single_infobox" tabindex="17" name="di_single_infobox">
									<option value="0" <?php if($this->di_getOptionValue('di_single_infobox') === 0){echo 'selected';}; ?>><?php _e('nein', 'dynamicinternet'); ?></option>
									<option value="1" <?php if($this->di_getOptionValue('di_single_infobox') === 1){echo 'selected';}; ?>><?php _e('ja', 'dynamicinternet'); ?></option>
								</select>
							</td>
							<td><?php _e('eine Infobox mit Tags/Kategorien etc. auf der Beitragsseite unterhalb des Artikels', 'dynamicinternet'); ?></td>
						</tr>
					</table>
					<table class="widefat">
						<thead>
							<tr>
								<th colspan="3"><?php _e('Einstellungen f&uuml;r den zus&auml;tzlichen Container', 'dynamicinternet'); ?></th>
							</tr>
						</thead> 
						<tr>
							<td width="20%" align="right"><?php _e('Textausrichtung Spalte 1', 'dynamicinternet'); ?>:</td>
							<td width="25%">
								<select id="di_subcol_1" tabindex="18" name="di_subcol_1">
									<option value="1" <?php if($this->di_getOptionValue('di_subcol_1') === 1){echo 'selected';}; ?>><?php _e('rechts', 'dynamicinternet'); ?></option>
									<option value="2" <?php if($this->di_getOptionValue('di_subcol_1') === 2){echo 'selected';}; ?>><?php _e('links', 'dynamicinternet'); ?></option>
									<option value="3" <?php if($this->di_getOptionValue('di_subcol_1') === 3){echo 'selected';}; ?>><?php _e('zentriert', 'dynamicinternet'); ?></option>
								</select>
							</td>
							<td><?php _e('von links nach rechts', 'dynamicinternet'); ?></td>
						</tr>
						<tr>
							<td width="20%" align="right"><?php _e('Textausrichtung Spalte 2', 'dynamicinternet'); ?>:</td>
							<td width="25%">
								<select id="di_subcol_2" tabindex="19" name="di_subcol_2">
									<option value="1" <?php if($this->di_getOptionValue('di_subcol_2') === 1){echo 'selected';}; ?>><?php _e('rechts', 'dynamicinternet'); ?></option>
									<option value="2" <?php if($this->di_getOptionValue('di_subcol_2') === 2){echo 'selected';}; ?>><?php _e('links', 'dynamicinternet'); ?></option>
									<option value="3" <?php if($this->di_getOptionValue('di_subcol_2') === 3){echo 'selected';}; ?>><?php _e('zentriert', 'dynamicinternet'); ?></option>
								</select>
							</td>
							<td><?php _e('von links nach rechts', 'dynamicinternet'); ?></td>
						</tr>
						<tr>
							<td width="20%" align="right"><?php _e('Textausrichtung Spalte 3', 'dynamicinternet'); ?>:</td>
							<td width="25%">
								<select id="di_subcol_3" tabindex="20" name="di_subcol_3">
									<option value="1" <?php if($this->di_getOptionValue('di_subcol_3') === 1){echo 'selected';}; ?>><?php _e('rechts', 'dynamicinternet'); ?></option>
									<option value="2" <?php if($this->di_getOptionValue('di_subcol_3') === 2){echo 'selected';}; ?>><?php _e('links', 'dynamicinternet'); ?></option>
									<option value="3" <?php if($this->di_getOptionValue('di_subcol_3') === 3){echo 'selected';}; ?>><?php _e('zentriert', 'dynamicinternet'); ?></option>
								</select>
							</td>
							<td><?php _e('von links nach rechts', 'dynamicinternet'); ?></td>
						</tr>
					</table>
			<div class="tablenav">
				<div class="alignleft">
					<input type="submit" name="yaml_config_save" value="<?php _e('Optionen speichern', 'dynamicinternet'); ?>" class="button-secondary"/>
					<input type="submit" name="yaml_config_default" value="<?php _e('Default Einstellungen laden', 'dynamicinternet'); ?>" class="button-secondary"/>
				</div>
				<br class="clear">
			</div>
			<br class="clear">
			</form>
		</div>
	<?php
		}
	}
}

$yamlconfig = new di_yaml_config();
global $yamlconfig;

add_action('admin_menu', array(&$yamlconfig, 'di_initAdmin'));
add_action('wp_head', array(new di_yaml_config(), 'di_loadStylesheets'));

// remove wp_recent_comments_style via Frank Bueltge
add_filter('wp_widget_recent_comments_style', create_function($a, 'return null;'));

function di_rss_info_widget($args) {
	extract($args);
	$widget = get_option('di_rss_info_widget');
	$title = empty($widget['title']) ? __('RSS feed abonnieren','dynamicinternet') : $widget['title'];
	$yamlconfig = new di_yaml_config;

	//links und links
	if ($yamlconfig->di_getOptionValue('di_txtalign') === 1 && $yamlconfig->di_getOptionValue('di_layout') === 2 ) {
		$feedicon = 'icon_left';
	//links und links/rechts
	} elseif ($yamlconfig->di_getOptionValue('di_txtalign') === 1 && $yamlconfig->di_getOptionValue('di_layout') === 3 ) {
		$feedicon = 'icon_left';
	} else {
		$feedicon = 'icon_right';
	}

	echo $before_widget;
	echo $before_title . $title . $after_title; ?>
	<ul id="di_rss" class="<?php echo $feedicon; ?>">
		<li><a href="<?php bloginfo('rss2_url'); ?>" rel="nofollow" title="<?php _e('abonniere mein Feed mit RSS','dynamicinternet'); ?>"><?php _e('Beitr&auml;ge'); ?></a></li>
		<li><a href="<?php bloginfo('comments_rss2_url'); ?>" rel="nofollow" title="<?php _e('alle Kommentare per RSS Feed', 'dynamicinternet'); ?>"><?php _e('Kommentare'); ?></a></li>
	</ul>
<?php echo $after_widget;
}

function di_widget_register() {
	if ( function_exists('register_sidebar') ) {
		$yamlconfig = new di_yaml_config;
		if($yamlconfig->di_getOptionValue('di_layout') === 3 || $yamlconfig->di_getOptionValue('di_secondsidebar') === 1 ) {
			$name = 'left Sidebar';
			register_sidebar(array(
				'name' => __('rechte Sidebar','dynamicinternet'),
		        'before_widget' => '<li id="%1$s" class="widget %2$s">',
		        'after_widget' => '</li>',
		        'before_title' => '<h3>',
		        'after_title' => '</h3>',
			));
		} else {
			$name = 'Sidebar';
		}

		register_sidebar(array(
			'name' => $name,
	        'before_widget' => '<li id="%1$s" class="widget %2$s">',
	        'after_widget' => '</li>',
	        'before_title' => '<h3>',
	        'after_title' => '</h3>',
		));

		if ($yamlconfig->di_getOptionValue('di_subcolumn') !== 0) {
			for ($i=1; $i<=$yamlconfig->di_getOptionValue('di_subcolumn'); $i++) {
				register_sidebar(array(
					'name' => 'Subcolumn' .$i,
			        'before_widget' => '<li id="%1$s" class="widget %2$s">',
			        'after_widget' => '</li>',
			        'before_title' => '<h3>',
			        'after_title' => '</h3>',
				));
			}
		}
	}
	$widget_ops = array('classname' => 'di_rss_info_widget', 'description' => __( 'Zeigt die Beitrags- und Kommentarfeed Links an', 'dynamicinternet' ) );
	wp_register_sidebar_widget('difeed', __('YAML RSS Widget', 'dynamicinternet'), 'di_rss_info_widget', $widget_ops);
}
add_action('widgets_init', 'di_widget_register', 1);

function di_last_comments($number) {
	global $wpdb;
	$number = (int) $number;
	$comments = $wpdb->get_results("SELECT comment_author, comment_author_url, comment_ID, comment_post_ID FROM $wpdb->comments WHERE comment_approved = '1' AND comment_type = '' ORDER BY comment_date_gmt DESC LIMIT $number");
?>
			<ul id="recentcomments"><?php
			if ( $comments ) : foreach ($comments as $comment) :
			echo '<li>' . $comment->comment_author . ' am 
			<a href="' . get_permalink($comment->comment_post_ID) .'#comment-'. $comment->comment_ID . '" title="' .get_the_title($comment->comment_post_ID) . '">'. get_the_title($comment->comment_post_ID) .'</a></li>';
			endforeach;
			else:
				echo '<li class="recentcomments">' . __('keine Kommentare','dynamicinternet') . '</li>';
			endif;?>
			</ul>
<?php
}

function di_last_trackPings($number) {
	global $wpdb;
	$number = (int) $number;
	$comments = $wpdb->get_results("SELECT comment_author, comment_author_url, comment_ID, comment_post_ID FROM $wpdb->comments WHERE comment_approved = '1' AND comment_type IN('trackback','pingback') ORDER BY comment_date_gmt DESC LIMIT $number");
?>
			<ul id="recenttrackbacks"><?php
			if ( $comments ) : foreach ($comments as $comment) :
				echo  '<li class="recentcomments">' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>';
			endforeach;
			else:
				echo '<li class="recentcomments">' . __('keine Ping/Trackbacks','dynamicinternet') . '</li>';
			endif;?>
			</ul>
<?php
}
?>
